home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume10 / tek < prev    next >
Encoding:
Text File  |  1990-02-20  |  23.1 KB  |  1,010 lines

  1. Newsgroups: comp.sources.misc
  2. organization: Maple Lawn Farm, Stonington, CT
  3. subject: v10i081: tek - yet another tek4014 emulator
  4. from: ron@mlfarm.uucp (Ronald Florence)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 10, Issue 81
  8. Submitted-by: ron@mlfarm.uucp (Ronald Florence)
  9. Archive-name: tek
  10.  
  11. Tek is yet another tek4014 emulator.  This one produces output through
  12. the SCO CGI drivers.  The code is written so that by modifying a
  13. single header file, the output can instead by created for other
  14. devices.  A sample header file for the Hewlett-Packard HP7470a plotter
  15. is included.
  16. __________________________________________________________________
  17. #! /bin/sh
  18. # This is a shell archive, meaning:
  19. # 1. Remove everything above the #! /bin/sh line.
  20. # 2. Save the resulting text in a file.
  21. # 3. Execute the file with /bin/sh (not csh) to create:
  22. #    Readme
  23. #    Makefile
  24. #    tek.c
  25. #    tekdecode.c
  26. #    tek4.h
  27. #    poly.c
  28. #    tekpts.c
  29. #    hp7470-tek4.h
  30. #    tek.man
  31. # This archive created: Mon Feb 19 08:02:50 1990
  32. # By:    Ronald Florence (Maple Lawn Farm, Stonington, CT)
  33. export PATH; PATH=/bin:/usr/bin:$PATH
  34. echo shar: "extracting 'Readme'" '(1739 characters)'
  35. if test -f 'Readme'
  36. then
  37.     echo shar: "will not over-write existing file 'Readme'"
  38. else
  39. sed 's/^X//' << \SHAR_EOF > 'Readme'
  40. X    tek - yet another tek4014 emulator
  41. X    copyright 1990 Ronald Florence
  42. X
  43. X    This package creates yet another tek4014 emulator.  On a
  44. X    Xenix system with the CGI package, the Makefile will create
  45. X    tek and poly (actually a link).  Tek reads tek4014 input and
  46. X    outputs it to any CGI device.  Poly reads ascii integer or
  47. X    floating point xy points.  Using the SCO CGI devices, we
  48. X    have successfully used tek and poly with a VGA, EGA, and CGA
  49. X    display, HP 7470a plotter, Laserjet, Deskjet, Epson
  50. X    printers, and a Postscript printer.  To use the CGI drivers,
  51. X    make sure you have the CGIPATH and CGIDISP or CGIPRNT
  52. X    environmental variables declared.  Tek and poly also
  53. X    recognize and work correctly with a Wyse wy99gt terminal
  54. X
  55. X    Command line options:
  56. X       Invoked as "tek":
  57. X          -w  reads Accu-Weather maps
  58. X       Invoked as "poly":
  59. X          -s  read xmin, ymin, xmax, ymax scaling points first 
  60. X          (default is 4096 x 3120)
  61. X       Both:
  62. X          -p  use plotter or printer device for output 
  63. X          (default is to use the display device)
  64. X          -a  preserve aspect ratio
  65. X
  66. X    The heart of the code is tekdecode.c, which has been written
  67. X    so that simple changes to tek4.h will adapt the emulator to
  68. X    devices other than CGI.  A tek4.h header file for the
  69. X    Hewlett-Packard HP7470a plotter is included as a sample.
  70. X    Tekdecode.c has also been successfully adapted to drive an
  71. X    Epson printer directly.
  72. X
  73. X    Permission is hereby granted for unlimited non-commercial
  74. X    use of these programs, on condition that the copyright
  75. X    notices are left intact and any modifications to the source
  76. X    code are noted as such.  No warranty of any kind is implied
  77. X    or granted for this material.
  78. X
  79. X    Ronald Florence            
  80. X    Maple Lawn Farm, Stonington, CT    
  81. X    ron@mlfarm.uu.net
  82. X    {yale,uunet}!hsi!mlfarm!ron
  83. SHAR_EOF
  84. if test 1739 -ne "`wc -c < 'Readme'`"
  85. then
  86.     echo shar: "error transmitting 'Readme'" '(should have been 1739 characters)'
  87. fi
  88. fi
  89. echo shar: "extracting 'Makefile'" '(447 characters)'
  90. if test -f 'Makefile'
  91. then
  92.     echo shar: "will not over-write existing file 'Makefile'"
  93. else
  94. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  95. X# tek makefile
  96. X# copyright 1990 Ronald Florence
  97. X
  98. XCFLAGS= -O
  99. XLDFLAGS= -lccgi -s
  100. XINSTALL_DIR = /u/bin
  101. XMAN_DIR = /usr/man/man.LOCAL
  102. X
  103. Xpoly:    tek
  104. X    ln tek poly
  105. X
  106. Xtek:    tek.o tekdecode.o poly.o tekpts.o
  107. X    cc tek.o tekdecode.o poly.o tekpts.o $(LDFLAGS) -o tek
  108. X
  109. Xtekdecode.o:    tek4.h
  110. X
  111. Xinstall: tek
  112. X    cp tek $(INSTALL_DIR)
  113. X    ln $(INSTALL_DIR)/tek $(INSTALL_DIR)/poly
  114. X    cp tek.man $(MAN_DIR)/tek
  115. X    ln $(MAN_DIR)/tek $(MAN_DIR)/poly
  116. X    rm -f tek poly
  117. X
  118. Xclean:
  119. X    rm -f *.o
  120. SHAR_EOF
  121. if test 447 -ne "`wc -c < 'Makefile'`"
  122. then
  123.     echo shar: "error transmitting 'Makefile'" '(should have been 447 characters)'
  124. fi
  125. fi
  126. echo shar: "extracting 'tek.c'" '(4298 characters)'
  127. if test -f 'tek.c'
  128. then
  129.     echo shar: "will not over-write existing file 'tek.c'"
  130. else
  131. sed 's/^X//' << \SHAR_EOF > 'tek.c'
  132. X/*
  133. X *  tek.c  
  134. X *  copyright 1988 Ronald Florence
  135. X *
  136. X *    as "tek" - Tek4014 picture files to CGI or WY99
  137. X *      -w  Accu-Weather maps
  138. X *    as "poly" - reads points for polyline on CGI or WY99
  139. X *      -s  read xmin, ymin, xmax, ymax scaling points first 
  140. X *          (default is 4096 x 3120)
  141. X *    both:
  142. X *      -p  use plotter or printer (default display)
  143. X *      -a  preserve aspect ratio
  144. X *
  145. X *    bugs: SIGINT doesn't work with wy99 modes.  Possible solution is to
  146. X *    poll terminal on every iteration, with terminal set in raw mode.
  147. X */
  148. X
  149. X#include  <signal.h>
  150. X#include  <stdio.h>
  151. X#include  <termio.h>
  152. X#include  <fcntl.h>
  153. X
  154. X#define  int        short        /* for CGI functions    */
  155. X#define     CRT        (wout[45] == 0)
  156. X#define     To_tek        "\033[?38h"
  157. X#define     To_vt220    "\033[?38l"
  158. X#define     Clr_tek    "\033\f"
  159. X#define  Vt_reset    "\033!p"
  160. X
  161. Xint    dev;            /* device id */
  162. Xstatic  int    tty;
  163. Xstruct  termio new, old;
  164. Xstatic  int  tek;        /* =1 if invoked as tek */
  165. Xstatic  char  *progn;
  166. Xstatic  char  *dspec[] = {"CGIDISP", "CGIPRNT", 0 };
  167. X
  168. Xmain (argc, argv)
  169. X     int    argc;
  170. X     char    **argv;
  171. X{
  172. X  FILE  *fi = stdin;
  173. X  int    win[19],         /* device input info */
  174. X           wout[66],         /* device output info */
  175. X        h = 0, 
  176. X    aspect = 0,        /* map to max CGI space */
  177. X    opt = 0,
  178. X    sig_handle(), quit_wyse();
  179. X    char    *device, *p, *getenv(), *strrchr(); 
  180. X
  181. X  progn = (p = strrchr(*argv, '/')) ? p + 1 : *argv;    
  182. X  tek = strcmp(progn, "poly");
  183. X  if (strlen(getenv("ASPECT")))
  184. X    aspect = 3;
  185. X
  186. X  while (argc-- && **++argv == '-') 
  187. X    for (p = *argv+1; *p; p++)
  188. X      switch (*p) 
  189. X    {
  190. X    case 'w' :
  191. X      if (tek)
  192. X        ++opt;
  193. X      else
  194. X        usage();
  195. X      break;
  196. X    case 's' :
  197. X      if (!tek)
  198. X        ++opt;
  199. X      else
  200. X        usage();
  201. X      break;
  202. X    case 'p' :
  203. X      ++h;
  204. X      break;
  205. X    case 'a' :
  206. X      aspect = 3;
  207. X      break;
  208. X    default :
  209. X      usage();
  210. X    }
  211. X                /* we cannot do freopen(stdin) for the */
  212. X                /* input because the CGI functions */
  213. X                /* read from stdin  */
  214. X  if (argc > 0 && (fi = fopen(*argv, "r")) == NULL)  
  215. X    {
  216. X      printf("%s: can't open %s\n", progn, *argv);
  217. X      exit (-1);
  218. X    }
  219. X                /* open /dev/tty to read keystrokes */
  220. X  tty = open("/dev/tty", O_RDWR);
  221. X  ioctl(tty, TCGETA, &new);
  222. X  ioctl(tty, TCGETA, &old);
  223. X                /* wyse 99 terminal? */
  224. X  if (!h && !strncmp(getenv("TERM"), "wy99", 4))
  225. X    {
  226. X                 /* not this easy, alas ... */
  227. X      signal(SIGINT, quit_wyse);
  228. X      printf("%s%s", To_tek, Clr_tek);
  229. X      if (tek)
  230. X    vt_tek(fi, opt);
  231. X      else
  232. X    tekpts(fi, opt);
  233. X      fflush(stdout);
  234. X      getkey();
  235. X      quit_wyse();
  236. X    }
  237. X                /* check for valid CGI device */
  238. X  for ( ; (device = dspec[h]) && getenv(dspec[h]) == NULL; h++) ;
  239. X  if (!device)
  240. X    {
  241. X      printf("%s: no device\n", progn);
  242. X      exit (-1);
  243. X    }
  244. X  signal( SIGHUP, sig_handle );
  245. X  signal( SIGINT, sig_handle );
  246. X  signal( SIGQUIT, SIG_IGN );
  247. X
  248. X  win[0] = aspect;
  249. X  win[1] = 1;            /* solid line */
  250. X  win[2] = 1;            /* line color */
  251. X  win[3] = 1;            /* marker type . */
  252. X  win[4] = 1;            /* marker color */
  253. X  win[5] = 1;            /* graphics text font */
  254. X  win[6] = 1;            /* graphics text color */
  255. X  win[7] = 0;            /* fill interior style */
  256. X  win[8] = 0;            /* fill style index */
  257. X  win[9] = 1;            /* fill color index */
  258. X  win[10] = 1;            /* prompt for paper changes */
  259. X  for (h = 0; device[h]; h++)
  260. X    win[11+h] = device[h];
  261. X  win[18] = ' ';
  262. X
  263. X  if (v_opnwk(win, &dev, wout) < 0) 
  264. X    {
  265. X      printf("%s: error %d opening %s\n", progn, -vq_error(), device);
  266. X      exit (-1);
  267. X    }    
  268. X  if (tek)
  269. X    tekdecode(fi, opt);
  270. X  else
  271. X    do_poly(fi, opt);
  272. X  if (CRT)  
  273. X    getkey();
  274. X  v_clswk(dev);
  275. X}
  276. X
  277. X
  278. Xusage ()
  279. X{
  280. X  printf("usage: %s file\n", tek ? "tek [-wpa]" : "poly [-spa]");
  281. X  exit (-1);
  282. X}
  283. X
  284. X
  285. Xerr (func)
  286. X     char  func[];
  287. X{
  288. X  int    errnum;
  289. X
  290. X  errnum = strcmp(func, "data") ? -(vq_error()) : 0;
  291. X  v_clswk(dev);
  292. X  if (errnum)
  293. X    printf ("%s: error no. %d in CGI function %s\n", progn, errnum, func);
  294. X  else
  295. X    printf (tek ? "tek: too many data points\n" : "poly: invalid scaling points\n");
  296. X  exit (-2);
  297. X}
  298. X
  299. X
  300. Xint  sig_handle (sig)
  301. X     int  sig;
  302. X{
  303. X  v_clswk( dev );
  304. X  exit( sig );
  305. X}
  306. X
  307. Xgetkey()
  308. X{
  309. X  char    c;
  310. X
  311. X  new.c_lflag &= ~(ECHO|ICANON);
  312. X  new.c_cc[VMIN] = 1;
  313. X  ioctl(tty, TCSETAW, &new);
  314. X  read(tty, &c, 1);
  315. X  ioctl(tty, TCSETA, &old);
  316. X}
  317. X
  318. Xint  quit_wyse ()        /* needs all of it to restore wy99 */
  319. X{
  320. X  fflush (stdout);
  321. X  fprintf (stderr, "%s%s", Clr_tek, To_vt220);
  322. X  sleep (1);
  323. X  fprintf (stderr, "%s", Vt_reset);
  324. X  exit (0);
  325. X}
  326. X
  327. SHAR_EOF
  328. if test 4298 -ne "`wc -c < 'tek.c'`"
  329. then
  330.     echo shar: "error transmitting 'tek.c'" '(should have been 4298 characters)'
  331. fi
  332. fi
  333. echo shar: "extracting 'tekdecode.c'" '(4503 characters)'
  334. if test -f 'tekdecode.c'
  335. then
  336.     echo shar: "will not over-write existing file 'tekdecode.c'"
  337. else
  338. sed 's/^X//' << \SHAR_EOF > 'tekdecode.c'
  339. X/*
  340. X *    tekdecode.c - converts Tek4014 picture files 
  341. X *    copyright 1988 Ronald Florence 
  342. X *
  343. X *    decoding algorithm from J. Tenenbaum (2/24/87)
  344. X *    alpha mode (2/21/88)
  345. X *    linetypes (5/12/88)
  346. X *    increment mode (5/23/88)
  347. X *    corrected algorithm (6/30/88)
  348. X */
  349. X
  350. X#include        <stdio.h>
  351. X#include    "tek4.h"
  352. X
  353. X#define US      0x1f
  354. X#define RS    0x1e
  355. X#define GS      0x1d
  356. X#define FS      0x1c
  357. X#define ESC    0x1b
  358. X#define BS      0x8
  359. X#define HT      0x9
  360. X#define LF      0xa
  361. X#define VT      0xb
  362. X
  363. X#define NONE        0
  364. X#define VECTOR      1
  365. X#define POINT       2
  366. X#define ALPHA       3
  367. X#define INCREMENT    4
  368. X
  369. X#define Low_Y        0x2
  370. X#define CTRL        0
  371. X#define HI        1
  372. X#define LOX        2
  373. X#define LOY        3
  374. X
  375. Xstatic    int    charht[4] = { 36, 40, 61, 66 },
  376. X        charwd[4] = { 24, 26, 40, 44 },
  377. X#ifdef WEATHER
  378. X        weather,
  379. X#endif
  380. X        cellw,            /* current width of a character cell */
  381. X        chsize = 3;         /* font */
  382. X
  383. X
  384. Xtekdecode (infile, opt) 
  385. X     FILE  *infile;
  386. X     int   opt;
  387. X{
  388. X  register    c, mode; 
  389. X  int    pts[Maxpts * 2], pn, got = 0, escape = 0, hisave, 
  390. X           tx, ty, lox, loy, hix, hiy, devx, devy;
  391. X  char    gstring[256], *g;
  392. X
  393. X  mode = NONE;
  394. X  Align(Left, Base);
  395. X  Set_charsize(chsize);
  396. X  while ((c = getc(infile)) != EOF) 
  397. X    {
  398. X      c &= 0x7f;
  399. X      if (escape) 
  400. X    {
  401. X      parse(c);
  402. X      escape = 0;
  403. X      continue;
  404. X    }
  405. X      if (c >> 5 == CTRL)
  406. X    {
  407. X      if (c == '\0')    /* they pad, we strip */
  408. X        continue;
  409. X      if (mode == ALPHA) 
  410. X        {
  411. X          *g = '\0';
  412. X          if (g > gstring)
  413. X        Wr_str(devx, devy, gstring);
  414. X          devx += (g - gstring) * cellw;
  415. X          mode = NONE;
  416. X        }
  417. X      if (mode == INCREMENT) 
  418. X        {
  419. X          tx *= xm;
  420. X          ty *= ym;
  421. X          Increment(tx, ty);
  422. X        }
  423. X      if (mode == VECTOR && pn)
  424. X        Vector(pn, pts);
  425. X      if (mode == POINT && pn) 
  426. X        Marker(pn, pts);
  427. X     
  428. X      switch (c) 
  429. X        {
  430. X        case BS:        /* cursor motions */
  431. X        case HT:        /* we'll do nothing */
  432. X        case VT:
  433. X          break;
  434. X        case GS:
  435. X          mode = VECTOR;
  436. X          pn = 0;
  437. X          break;
  438. X        case FS:
  439. X          mode = POINT;
  440. X          pn = 0;
  441. X          break;
  442. X        case US:
  443. X          g = gstring;
  444. X          mode = ALPHA;
  445. X          break;
  446. X        case ESC :
  447. X          ++escape;
  448. X          break;
  449. X        case RS :
  450. X          mode = INCREMENT;
  451. X          tx = 0;
  452. X          ty = 0;
  453. X          break;
  454. X        case LF:        /* clear bypass */
  455. X          mode = NONE;
  456. X          break;
  457. X        }
  458. X      continue;
  459. X    }
  460. X                /* else not a control char */
  461. X#ifdef WEATHER
  462. X      if (opt && weather)  
  463. X    {
  464. X      weather = 0;    
  465. X      if (c == 'P')        /* bailout at "PRESS" */
  466. X        return;
  467. X      if (c == 'c' && chsize == 0) /* tiny "c" for (c) */
  468. X        Switch_pen();
  469. X    }
  470. X#endif
  471. X      switch (mode) 
  472. X    {
  473. X    case NONE:
  474. X      continue;
  475. X    case VECTOR:
  476. X    case POINT :
  477. X      switch (c >> 5)
  478. X        {
  479. X        case HI:
  480. X          hisave = c & ~0x20;
  481. X          got |= HI;
  482. X          break;
  483. X        case LOY:
  484. X          loy = c & ~0x60;
  485. X          got |= Low_Y;
  486. X          if (got & HI) 
  487. X        {
  488. X          hiy = hisave;
  489. X          got &= ~HI;
  490. X        }
  491. X          break;
  492. X        case LOX:
  493. X          lox = c & ~0x40;
  494. X          if (got & HI)
  495. X        {
  496. X          if (got & Low_Y)
  497. X            hix = hisave;
  498. X          else
  499. X            hiy = hisave;
  500. X        }
  501. X          got &= ~(HI | Low_Y);
  502. X                      /* process the coordinates */
  503. X          tx = ((hix << 5) + lox) << 2;
  504. X          ty = ((hiy << 5) + loy) << 2;
  505. X          devx = tx * xm + xscale;
  506. X          devy = ty * ym + yscale;
  507. X          pts[pn++] = devx;
  508. X          pts[pn++] = devy;
  509. X          if (pn > Maxpts * 2)
  510. X        err("data");
  511. X          break;
  512. X        }
  513. X      break;
  514. X    case ALPHA:
  515. X      *g++ = c;
  516. X      break;
  517. X    case INCREMENT:
  518. X      switch (c) 
  519. X        {
  520. X        case ' ':
  521. X          break;
  522. X        case 'D':        /* north */
  523. X          ++ty;
  524. X          break;
  525. X        case 'H':        /* south */
  526. X          --ty;
  527. X          break;
  528. X        case 'A':        /* east */
  529. X          ++tx;
  530. X          break;
  531. X        case 'B':        /* west */
  532. X          --tx;
  533. X          break;
  534. X        case 'E':        /* northeast */
  535. X          ++ty;
  536. X          ++tx;
  537. X          break;
  538. X        case 'J':        /* southwest */
  539. X          --ty;
  540. X          --tx;
  541. X          break;
  542. X        }
  543. X      break;
  544. X    }
  545. X    }
  546. X}
  547. X
  548. X
  549. Xparse(inch)
  550. X     int  inch;
  551. X{
  552. X  int    ltype = NONE;
  553. X
  554. X  switch (inch) 
  555. X    {
  556. X    case '\f':
  557. X      Clear_scr();
  558. X      break;
  559. X    case '`' : 
  560. X    case 'e' :
  561. X    case 'f' :
  562. X    case 'g' :
  563. X    case 'h' :
  564. X    case 'm' :
  565. X    case 'n' :
  566. X    case 'o' :
  567. X      ltype = Solid;
  568. X      break;
  569. X    case 'a' :
  570. X    case 'i' :
  571. X      ltype = Dotted;
  572. X      break;
  573. X    case 'b' :
  574. X    case 'j' :
  575. X      ltype = Dotdash;
  576. X      break;
  577. X    case 'c' :
  578. X    case 'k' :
  579. X      ltype = Shortdash;
  580. X      break;
  581. X    case 'd' :
  582. X    case 'l' :
  583. X      ltype = Longdash;
  584. X      break;
  585. X    case '8' :
  586. X    case '9' :
  587. X    case ':' :
  588. X    case ';' :
  589. X      Set_charsize (chsize = ';' - inch);
  590. X#ifdef WEATHER
  591. X      ++weather;
  592. X#endif
  593. X      break;
  594. X    }
  595. X  if (ltype > 0)
  596. X    Set_line(ltype);
  597. X}
  598. SHAR_EOF
  599. if test 4503 -ne "`wc -c < 'tekdecode.c'`"
  600. then
  601.     echo shar: "error transmitting 'tekdecode.c'" '(should have been 4503 characters)'
  602. fi
  603. fi
  604. echo shar: "extracting 'tek4.h'" '(1219 characters)'
  605. if test -f 'tek4.h'
  606. then
  607.     echo shar: "will not over-write existing file 'tek4.h'"
  608. else
  609. sed 's/^X//' << \SHAR_EOF > 'tek4.h'
  610. X/*
  611. X *    tek4.h - CGI version
  612. X *    copyright 1988 Ronald Florence
  613. X */
  614. X
  615. X#define WEATHER        1
  616. X#define Maxpts        1000
  617. X#define    int        short    /* for CGI functions    */
  618. X#define Tekx        4096.0
  619. X#define Teky        3120.0
  620. X#define Vmax        31000    /* Tek programs cheat! */
  621. X#define Hmax        32000
  622. X
  623. Xdouble    xm = Hmax / Tekx,
  624. X    ym = Vmax / Teky,
  625. X    xscale = (32768 - Hmax) / 2.0,
  626. X    yscale;
  627. X
  628. X#define Left        0    /* character alignment  */
  629. X#define Base        0
  630. X#define Solid        1    /* linetypes */
  631. X#define Longdash    2
  632. X#define Dotted        3
  633. X#define Dotdash        4
  634. X#define Shortdash    7
  635. X#define Altcolor    2    /* red */
  636. X
  637. X
  638. Xextern    int    dev;        /* device handle */
  639. X
  640. X#define Align(H, V)    {                        \
  641. X            int    gh, gv;                    \
  642. X            vst_alignment(dev, Left, Base, &gh, &gv);    \
  643. X            }
  644. X#define Clear_scr()    /*  v_clrwk(dev)  */
  645. X#define Set_line(L)    vsl_type(dev, L)
  646. X#define Increment(X,Y)    
  647. X#define Switch_pen()    {                    \
  648. X            vst_color(dev, Altcolor);    \
  649. X            vsl_color(dev, Altcolor);    \
  650. X            vsm_color(dev, Altcolor);    \
  651. X            }
  652. X
  653. X#define Set_charsize(s)    {                        \
  654. X            int    chh, chw, cellh;                \
  655. X            chh = charht[s] * ym;                    \
  656. X            vst_height(dev, chh, &chw, &cellw, &cellh);    \
  657. X            }
  658. X#define    Vector(N, PTS)    v_pline(dev, (N/2), PTS)
  659. X#define Marker(N, PTS)    v_pmarker(dev, (N/2), PTS)
  660. X#define Wr_str(X, Y, p)    v_gtext(dev, X, Y, p)
  661. SHAR_EOF
  662. if test 1219 -ne "`wc -c < 'tek4.h'`"
  663. then
  664.     echo shar: "error transmitting 'tek4.h'" '(should have been 1219 characters)'
  665. fi
  666. fi
  667. echo shar: "extracting 'poly.c'" '(1452 characters)'
  668. if test -f 'poly.c'
  669. then
  670.     echo shar: "will not over-write existing file 'poly.c'"
  671. else
  672. sed 's/^X//' << \SHAR_EOF > 'poly.c'
  673. X/*
  674. X *    poly.c 
  675. X *    copyright 1988 Ronald Florence
  676. X */
  677. X
  678. X#include        <stdio.h>
  679. X
  680. X#define    int    short        /* for CGI functions    */
  681. X#define Maxpts  1000
  682. X#define Vdimax  32000
  683. X#define Tekx    4096.0
  684. X#define Teky    3120.0
  685. X
  686. Xextern int    dev;        /* device id */
  687. X
  688. Xstatic double  xscale = Vdimax / Tekx,
  689. X               yscale = Vdimax / Teky;
  690. X
  691. X
  692. Xdo_poly (infile, scaled)
  693. X     FILE  *infile;
  694. X     int   scaled;
  695. X{
  696. X  double  ix, iy, txlo, txhi, tylo, tyhi;
  697. X  int  ptc = 0, pts [Maxpts], xadd = 0, yadd = 0;
  698. X
  699. X  if (scaled) {
  700. X                /* read and check the scaling points */
  701. X    if ( fscanf(infile, "%lf%lf%lf%lf", &txlo, &tylo, &txhi, &tyhi ) == EOF 
  702. X    || txlo >= txhi
  703. X    || tylo >= tyhi )
  704. X      err ("data");
  705. X                /* rescale */
  706. X    xscale = Vdimax / (txhi - txlo);
  707. X    yscale = Vdimax / (tyhi - tylo);
  708. X    xadd = -txlo * xscale;
  709. X    yadd = -tylo * yscale;
  710. X  }
  711. X                /* read one xy point at a time */
  712. X  while ( fscanf(infile, "%lf%lf", &ix, &iy) != EOF )  {
  713. X                /* put them out when we have Maxpts / 2 */
  714. X    if ( ptc >= Maxpts )  {
  715. X    if (v_pline (dev, (ptc / 2), pts) < 0 )  
  716. X      err ("v_pline");
  717. X                /* copy the last points to the first */
  718. X    pts [0] = pts [ptc -2];
  719. X    pts [1] = pts [ptc -1];
  720. X                /* and set counter to start over */
  721. X    ptc = 2;
  722. X    }
  723. X                /* scale the points for the array */
  724. X    pts [ptc++] = ix * xscale + xadd;
  725. X    pts [ptc++] = iy * yscale + yadd;
  726. X  }
  727. X                /* make sure we get the tail end */
  728. X  if ( ptc > 2 && v_pline (dev, (ptc / 2), pts) < 0 )  
  729. X    err ("v_pline");
  730. X}
  731. SHAR_EOF
  732. if test 1452 -ne "`wc -c < 'poly.c'`"
  733. then
  734.     echo shar: "error transmitting 'poly.c'" '(should have been 1452 characters)'
  735. fi
  736. fi
  737. echo shar: "extracting 'tekpts.c'" '(1952 characters)'
  738. if test -f 'tekpts.c'
  739. then
  740.     echo shar: "will not over-write existing file 'tekpts.c'"
  741. else
  742. sed 's/^X//' << \SHAR_EOF > 'tekpts.c'
  743. X/*
  744. X *  tekpts.c
  745. X *  copyright 1988 Ronald Florence 
  746. X */
  747. X
  748. X#include <stdio.h>
  749. X
  750. X#define     Tekx      4096.0
  751. X#define     Teky      3120.0
  752. X
  753. Xvt_tek (infile, weather)
  754. X     FILE    *infile;
  755. X     int    weather;
  756. X{
  757. X     register    c, escape = 0;
  758. X
  759. X     while ((c = getc(infile)) != EOF)
  760. X       {
  761. X     if (weather)
  762. X       switch (escape)
  763. X         {
  764. X         case 0 :
  765. X           if (c == 0x1b)    /* escape */
  766. X         escape = 1;
  767. X           break;
  768. X         case 1 :
  769. X           escape = (c >= '8' && c <= ';') ? 2 : 0;
  770. X           break;
  771. X         case 2 :
  772. X           if (c == 'P')
  773. X         return;
  774. X           escape = 0;
  775. X           break;
  776. X         }
  777. X     putchar(c);
  778. X       }
  779. X   }
  780. X
  781. X
  782. Xtekpts (infile, scaled)
  783. X     FILE  *infile;
  784. X     int   scaled;
  785. X{
  786. X  register tx, ty;
  787. X  double  xscale = 1.0, yscale = 1.0, ix, iy, sxlo, sxhi, sylo, syhi;
  788. X  int        xadd = 0, yadd = 0;
  789. X
  790. X  if (scaled)
  791. X    {
  792. X                /* read and check the scaling points */
  793. X      if ( fscanf(infile, "%lf%lf%lf%lf", &sxlo, &sylo, &sxhi, &syhi ) == EOF 
  794. X      || sxlo >= sxhi
  795. X      || sylo >= syhi )
  796. X    err ("data");
  797. X                /* rescale */
  798. X      xscale = Tekx / (sxhi - sxlo);
  799. X      yscale = Teky / (syhi - sylo);
  800. X      xadd = -sxlo * xscale;
  801. X      yadd = -sylo * yscale;
  802. X    }
  803. X
  804. X  putchar(0x1d);        /* tek vector mode */
  805. X  while ( fscanf(infile, "%lf%lf", &ix, &iy) != EOF )
  806. X    {
  807. X      tx = ix * xscale + xadd;
  808. X      ty = iy * yscale + yadd;
  809. X                /* clip */
  810. X      if (tx >= Tekx)
  811. X    tx = Tekx - 1;
  812. X      if (tx < 0)
  813. X    tx = 0;
  814. X      if (ty >= Teky)
  815. X    ty = Teky -1;
  816. X      if (ty < 0)
  817. X    ty = 0;
  818. X                /* The fancy way is to send hiy, */
  819. X                /* loy, and hix only when they change. */
  820. X                /* This works.   We shift the high */
  821. X                /* part by 7 instead of 5 and shift */
  822. X                /* the low part by 2 because we scale */
  823. X                /* the Tek at 4096 x 3120 */
  824. X      putchar(0x20 | ((ty >> 7) & 0x1f)); /* hi y */
  825. X      putchar(0x60 | ((ty >> 2) & 0x1f)); /* low y */
  826. X      putchar(0x20 | ((tx >> 7) & 0x1f)); /* hi x */
  827. X      putchar(0x40 | ((tx >> 2) & 0x1f)); /* low x */
  828. X    }
  829. X  putchar(0x1f);        /* end tek vector mode */
  830. X}
  831. X
  832. SHAR_EOF
  833. if test 1952 -ne "`wc -c < 'tekpts.c'`"
  834. then
  835.     echo shar: "error transmitting 'tekpts.c'" '(should have been 1952 characters)'
  836. fi
  837. fi
  838. echo shar: "extracting 'hp7470-tek4.h'" '(1479 characters)'
  839. if test -f 'hp7470-tek4.h'
  840. then
  841.     echo shar: "will not over-write existing file 'hp7470-tek4.h'"
  842. else
  843. sed 's/^X//' << \SHAR_EOF > 'hp7470-tek4.h'
  844. X/*
  845. X *    tek4.h - hp7470a version
  846. X *    copyright 1987 Ronald Florence
  847. X */
  848. X
  849. X#define WEATHER        1
  850. X#define Maxpts        1000
  851. X
  852. X#define Points        0
  853. X#define Solid        1
  854. X#define Longdash    2
  855. X#define Dotted        3
  856. X#define Dotdash        4
  857. X#define Shortdash    5
  858. X#define Altcolor    2
  859. X
  860. Xextern    FILE    *plw;        /* plotter write file */
  861. Xextern    int    quit();        /* baleout function */
  862. Xextern    double    xm,        /* scalars */
  863. X        ym,
  864. X        xscale,
  865. X        yscale;
  866. X
  867. X
  868. Xchar    *linetype[] = {
  869. X        "LT0",        /* Points */
  870. X        "LT",        /* Solid */
  871. X        "LT3",        /* Longdash */
  872. X        "LT1,1",    /* Dotted */
  873. X        "LT4",        /* Dotdash */
  874. X        "LT2"        /* Shortdash */
  875. X    };
  876. X
  877. X
  878. X#define Clear_scr()
  879. X#define Align(H, V)
  880. X#define Set_line(L)    fprintf(plw, "%s", linetype[L])
  881. X#define Increment(X,Y)    fprintf(plw, "PU%d,%d", X, Y)
  882. X#define Wr_str(X, Y, p)    fprintf(plw, "LB%s\03", p)
  883. X#define Switch_pen()    fprintf(plw, "SP%d", Altcolor)
  884. X
  885. X#define Set_charsize(s)    cellw = charwd[s] * xm * (3 / 2);        \
  886. X            fprintf(plw, "SI%.3f,%.3f",             \
  887. X                charwd[s] * xm /400, charht[s] * ym /400)
  888. X
  889. X#define    Vector(N, PTS)    plot(N, PTS)
  890. X
  891. X#define Marker(N, PTS)    {            \
  892. X            Set_line (Points);    \
  893. X            plot (N, PTS);        \
  894. X            Set_line (Solid);    \
  895. X            }
  896. X
  897. X#define err(a)        if (!strcmp(a, "data"))                      \
  898. X            fprintf(stderr, "hp: too many data points\n"), quit()
  899. X        
  900. X
  901. Xplot (num, points)
  902. X     int  num, points[];
  903. X{
  904. X  register    i;
  905. X    
  906. X  fprintf(plw, "PU%d,%d", points[0], points[1]);
  907. X  if (num > 2) 
  908. X    {    
  909. X      fprintf(plw, "PD");
  910. X      for (i = 2; i < num - 1; i++) 
  911. X    fprintf(plw, "%d,", points[i]);
  912. X      fprintf(plw, "%d", points[i]);
  913. X    }
  914. X}
  915. SHAR_EOF
  916. if test 1479 -ne "`wc -c < 'hp7470-tek4.h'`"
  917. then
  918.     echo shar: "error transmitting 'hp7470-tek4.h'" '(should have been 1479 characters)'
  919. fi
  920. fi
  921. echo shar: "extracting 'tek.man'" '(1550 characters)'
  922. if test -f 'tek.man'
  923. then
  924.     echo shar: "will not over-write existing file 'tek.man'"
  925. else
  926. sed 's/^X//' << \SHAR_EOF > 'tek.man'
  927. X.TH TEK LOCAL
  928. X.SH NAME
  929. Xtek \- Tektronics 4010/14 post-processor
  930. X.br
  931. Xpoly \- displays polygon from XY points
  932. X.SH SYNOPSIS
  933. X.B tek
  934. X[
  935. X.I -wap
  936. X] [
  937. X.I file
  938. X]
  939. X.br
  940. X.B poly
  941. X[
  942. X.I -sap
  943. X] [
  944. X.I file
  945. X]
  946. X.SH DESCRIPTION
  947. X.PP
  948. XThe 
  949. X.I tek
  950. Xfilter displays files formatted for the Tektronics 4010/14 terminal on
  951. Xa CGI device or on the Wyse 99\s-2GT\s0 terminal.  The
  952. X.I -w
  953. Xoption parses an Accu-Weather map for multi-color output devices.
  954. X.PP
  955. X.I Poly
  956. Xdraws a polygon from a list of XY points in ascii integer or floating
  957. Xpoint format on a CGI device or on the Wyse 99\s-2GT\s0 terminal.  The
  958. Xpoints are expected to be scaled to the Tectronics (4096 \(mu 3120)
  959. Xscreen unless the
  960. X.I -s
  961. Xoption is used to specify that the first two sets of points represent 
  962. X.SM XMIN,
  963. X.SM YMIN
  964. Xand
  965. X.SM XMAX,
  966. X.SM YMAX.
  967. X.PP
  968. XThe
  969. X.I -p
  970. Xoption may be used with both 
  971. X.I tek
  972. Xand
  973. X.I poly
  974. Xto select the hardcopy CGI output device specified by the 
  975. X.SM CGIPRNT
  976. Xenvironment variable when a device specified by the
  977. X.SM CGIDISP 
  978. Xenvironment variable or the 
  979. X.SM WY99 
  980. Xterminal is the default output device.
  981. X.PP
  982. XThe
  983. X.I -a 
  984. Xoption specifies a square aspect ratio instead of the maximum space
  985. Xavailable on the CGI output device.  The square aspect ratio can also
  986. Xbe specified by declaring a (non-null)
  987. X.SM ASPECT 
  988. Xenvironment variable.  
  989. X.SH BUGS
  990. XThe available type sizes on CGI output devices may not match the
  991. XTektronics display.  The interactive Tektronics input functions are
  992. Xnot supported.  
  993. X.SH AUTHOR
  994. XRonald Florence (ron@mlfarm).  The Tektronics decoding algorithm was
  995. Xsuggested by Joel Tenenbaum.
  996. SHAR_EOF
  997. if test 1550 -ne "`wc -c < 'tek.man'`"
  998. then
  999.     echo shar: "error transmitting 'tek.man'" '(should have been 1550 characters)'
  1000. fi
  1001. fi
  1002. exit 0
  1003. #    End of shell archive
  1004. --
  1005.  
  1006. Ronald Florence            ron@mlfarm.uu.net
  1007.                 {yale,uunet}!hsi!mlfarm!ron
  1008.  
  1009.  
  1010.